<%-- 
    Document   : friendsSide
    Created on : 14/Jan/2012, 14:19:36
    Author     : sexta13
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<script type="text/javascript">
$(document).ready(function() {
	
	function gup( name ) {
        name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
        var regexS = "[\\?&#]"+name+"=([^&#]*)";
        var regex = new RegExp( regexS );
        var results = regex.exec( window.location.href );
        if( results == null )
            return "";
        else
            return results[1];
    }
	
    if(window.location.hash.length != 0) {
       	var url = "http://192.168.160.2:8080/feedsreader/AdicionarUtilizadorFb.action?chave="+ gup('access_token');
       	$.ajax({
       		url: url,
       		success: function ( result ) {
       			console.log(result);
       			$("#fbBox").html(result);
       		}
       	});
        //$(location).attr('href',url);
	} else {
        
		if( $("#oauthId").val() !== '' ) {
			$(location).attr('href',"https://www.facebook.com/dialog/oauth?client_id=354514694563340&redirect_uri=http://192.168.160.2:8080/feedsreader/InitFeedsReaderAction.action&scope=email,read_stream,read_friendlists,publish_stream&response_type=token");
		}	
	}
	
});
</script>

<s:hidden id="oauthId" value="%{oauthId}" name="oauthId"></s:hidden>

<div id="rightcolumn">
    <div class="rightbox_wrapper">
        <div id="fbBox" class="rightbox">
        	
            <p> Take a look at what your friend's are reading on Facebook, clicking <a id="loginFB" href="https://www.facebook.com/dialog/oauth?client_id=354514694563340&redirect_uri=http://192.168.160.2:8080/feedsreader/InitFeedsReaderAction.action&scope=email,read_stream,read_friendlists,publish_stream&response_type=token">here</a>
            <!-- <p> Take a look at what your friend's are reading on Twitter, clicking <a href="http://192.168.160.2:8080/feedsreader/TwitterOAuthRequestAction.action">here</a>  -->  
        </div>    
    </div>
</div>


<!-- Vai servir para quando for dada a autorização-->
<br></br><br></br>
<div id="rightcolumn">
    <div class="rightbox_wrapper">
        <div class="rightbox">                    
             <p> Take a look at what your friend's are reading on Twitter, clicking <a href="http://192.168.160.2:8080/feedsreader/TwitterOAuthRequestAction.action">here</a>  
        </div>
    </div>
</div>

<!-- Vai servir para quando for dada a autorização-->
<br></br><br></br>
<div id="rightcolumn">
    <div class="rightbox_wrapper">
        <div id="SapoGamesRss" class="rightbox">
        
        </div>
    </div>
</div>
